<?php
declare (strict_types = 1);
/**
 * 素材模型
 */
namespace app\common\model;

class Material extends BaseModel
{
    // 设置当前模型对应的完整数据表名称
    protected $table = 't_mat_info';

    /**
     * 素材列表
     */
    public function matList($whereAdmin = [], $whereRole = [], $offset = 1, $length = 20, $ordername, $order="desc")
    {
        $field = '*';

        $list = self::field($field)->where($whereAdmin)->limit(($offset-1) * $length, $length)->order([$ordername => $order])->select();

        $count = self::where($whereAdmin)->count('mat_id');

        $sumLength = self::where($whereAdmin)->sum('file_len');

        return [
            'list'  => $list,
            'total' => $count,
            'pagenum' => $offset,
            'sumlength' => $sumLength
        ];        
    }
}
